//
//  HWlibaoxiangqingTableViewCell.m
//  HWanGame
//
//  Created by 陈道斌 on 2020/11/27.
//  Copyright © 2020 Chendaobin. All rights reserved.
//

#import "HWlibaoxiangqingTableViewCell.h"
#import "HWlibaocellTableViewCell.h"
#import "HWlibaoxiangqingjiemianModel.h"
#import "HWLoginController.h"
#import "HWlibaobagtankuanView.h"





@interface HWlibaoxiangqingTableViewCell()<UITableViewDelegate,UITableViewDataSource>
@property(strong,nonatomic) UITableView *mainaTableVie;
@end

@implementation HWlibaoxiangqingTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
         
        [self setupUI];
        
        
        
    }
    
    
    
    return  self;
    
    
}



- (void)setupUI   {
    
      self.mainaTableVie = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenW,  450) style:UITableViewStylePlain];
      self.mainaTableVie.backgroundColor = [UIColor whiteColor];
      self.mainaTableVie.backgroundColor = RGB(247, 247, 247);
      self.mainaTableVie.delegate = self;
      self.mainaTableVie.dataSource = self;
      self.mainaTableVie.tag = 10;
    //  self.maintablview.scrollEnabled = NO;
      self.mainaTableVie.separatorStyle =  UITableViewCellSeparatorStyleNone;
      self.mainaTableVie.tableFooterView = [[UIView alloc]init];
      self.mainaTableVie.showsVerticalScrollIndicator = NO;
      [self.contentView addSubview:self.mainaTableVie];
    
    
}



- (void)shuxingshuju {
    
    
    self.mainaTableVie.frame = CGRectMake(0, 0, kScreenW, self.dataMuArr.count*92);
    
    [self.mainaTableVie reloadData];
    
    
    
    
    
    
}





/*

// 发送网络请求
- (void)fasongwangluoqingqiu  {
    
    
      NSDictionary *parametes = @{
                                      @"ct" :  @"app",
                                      @"ac" : @"game_lb",
                                      @"ios" : @"1",
                                      @"member_id":[HWLocallyStoredData getCode],
                                      @"gid": self.gidStr,
                                      
                                      };
          
          
        
          
          [HWWebUtils do3GetWithParameters:parametes progress:nil success:^(id response) {
              
              
              NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
             
            
              [MBProgressHUD hideHUD];
              
            
              
              
              if ([codeStr intValue] == 1) {
                //  [MBProgressHUD  showError:@"加载成功"];
                   //    NSArray *arr = response[@"data"];
                self.dataMuArr = [HWlibaoxiangqingjiemianModel mj_objectArrayWithKeyValuesArray:response[@"data"][@"list"]];
//
//    //                  self.p = [NSString stringWithFormat:@"%@",response[@"p"]];
//    //
//    //                  self.max_p = [NSString stringWithFormat:@"%@",response[@"max_p"]];
//    //
//                      [self.maincollectionView reloadData];
//
 //                  NSString *iconStr = response[@"data"][@"icon"];

 //                  [self.icoIamgeView sd_setImageWithURL:[NSURL URLWithString:iconStr] placeholderImage:nil];
                  
//                  self.biatiuLabe.text = [NSString stringWithFormat:@"%@",response[@"data"][@"name"]];
//
//                  self.mingchenglabel.text = [NSString stringWithFormat:@"%@",response[@"data"][@"name"]];
//
//                  [self.starsBut setTitle:[NSString stringWithFormat:@"%@ %@",response[@"data"][@"point"],response[@"data"][@"type"]] forState:UIControlStateNormal];
//
//                   [self.starsBut layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:3];
                  
                  [self.mainaTableVie reloadData];
                  

                
                  
                  
              } else {
                  
                  self.dataMuArr = [[NSMutableArray alloc]init];
                  
                  [MBProgressHUD showError:response[@"message"]];
                  
                  
                  
                 //  [self.maincollectionView reloadData];
               
                  
              }
              NSLog(@"%@",response);
              
              
          } failure:^(NSString *error) {
              
             
              
              
          }];
    
    
    
    
}
 
 
*/




// 添加tablview
- (void)tianjiamnTabView {
    
   //   [self.view addSubview:self.mainaTableVie];
    
    
}














- (void)buttonTouxiangTap  {
    

    NSLog(@"1234554");
    
    
}








- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

   
    
     return   self.dataMuArr.count;





}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *cellID = @"YouXiID";
    HWlibaocellTableViewCell   *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
   
    if (!cell) {
        cell =  [[NSBundle mainBundle]loadNibNamed:@"HWlibaocellTableViewCell" owner:nil options:nil].firstObject;
        
    }
    
    cell.selectionStyle =  UITableViewCellSelectionStyleNone;
//
    HWlibaoxiangqingjiemianModel *mdoel = self.dataMuArr[indexPath.row];

    
    
    [cell.icoiamgeView sd_setImageWithURL:[NSURL URLWithString:mdoel.bgimg] placeholderImage:nil];
    cell.mingchengLabel.text = [NSString stringWithFormat:@"%@",mdoel.cardname];
    cell.jieshaoLabel.text = [NSString stringWithFormat:@"%@",mdoel.content];

//    CGFloat  bfb = [mdoel.bfb floatValue]/100;
//    cell.jingdutiaoProgreaView.progress = bfb;
//    cell.shengyuLabel.text = [NSString stringWithFormat:@"剩余 %d%%",100 - [mdoel.bfb intValue]];
//
//
     CGFloat  bfb = [mdoel.bfb floatValue]/100;
       cell.jingdutiaoProgreaView.progress = bfb;
       cell.shengyuLabel.text = [NSString stringWithFormat:@"剩余 %d%%",[mdoel.bfb intValue]];

    
    
    
    

    [cell.beijingyanseBut addTarget:self action:@selector(beijingyanseButTap:) forControlEvents:UIControlEventTouchUpInside];



    
    
    return  cell;
    
    
    
    
    
    
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

   
    return 92;
    

 


}
 



- (void)beijingyanseButTap:(UIButton *)sender {
    
    NSLog(@"%@",[[[sender superview] superview]superview]);
    
    HWlibaocellTableViewCell *cell = (HWlibaocellTableViewCell *)[[[sender superview] superview]superview];
    
    
    NSIndexPath *index =  [self.mainaTableVie indexPathForCell:cell];
    
    
    HWlibaoxiangqingjiemianModel *mdoel =   self.dataMuArr[index.row];
    
    
    
    
    

//    if ([[HWLocallyStoredData getLoginUserID] isEqualToString:@""]) {
//             HWLoginController  *login = [[HWLoginController alloc]init];
//               [self.navigationController pushViewController:login animated:YES];
//              return;
//
//     }
    
    
    
    
    NSString *userID = [HWLocallyStoredData getLoginUserID];
    
    
    
    
           NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
           NSString *sign = [NSString stringWithFormat:@"%@%@%@",userID,tStr,@"fsd213ewdsadqwe2121213edsad"];
           NSString *signMD5 = [WMUtil md5HexDigest:sign];
    
     NSDictionary *parametes = @{
                                          @"ct" :  @"app",
                                          @"ac" : @"get_lb",
                                          @"uid":userID,
                                          @"t":tStr,
                                          @"sign":signMD5,
                                          @"id": mdoel.id,
                                          @"ios" : @"1",
                                          @"member_id":[HWLocallyStoredData getCode],
                                
                                          
                                          };
              
              
            
              
              [HWWebUtils do3GetWithParameters:parametes progress:nil success:^(id response) {
                  
                  
                  NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
                 
                
                  [MBProgressHUD hideHUD];
                  
                
                  
                  
                  if ([codeStr intValue] == 1) {

                               
                                           HWlibaobagtankuanView  *biaoqian = [[HWlibaobagtankuanView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
                                                             
                                                             biaoqian.zifuchuanStr  = [NSString stringWithFormat:@"%@",response[@"data"]];
                                                             
                                                             [kKeyWindow addSubview:biaoqian];
                                                             
                                                             
                   
                    
                      
                      
                  } else {
                      
                    
                      
                      [MBProgressHUD showError:response[@"message"]];
                      
                      
                      
                     //  [self.maincollectionView reloadData];
                   
                      
                  }
                  NSLog(@"%@",response);
                  
                  
              } failure:^(NSString *error) {
                  
                 
                  
                  
              }];
        
    
    
}




 

@end
